import * as THREE from 'three';
const textureLoader = new THREE.TextureLoader();

export default class {
  mesh = new THREE.Group();
  material: THREE.MeshBasicMaterial;
  bodyMaterial: THREE.MeshBasicMaterial;
  constructor(color = '#fff', color2 = '#000') {
    this.createMaterial(color);
    this.createBodyMaterial(color2);
    this.createMesh();
  }
  setColor(color) {
    this.material.color = new THREE.Color(color);
  }
  createMesh() {
    this.mesh.add(new THREE.Mesh(new THREE.SphereGeometry(1000, 128, 128), this.material));
    this.mesh.add(new THREE.Mesh(new THREE.SphereGeometry(999, 128, 128), this.bodyMaterial));
  }
  createMaterial(color) {
    var img = textureLoader.load('images/opacityMap.jpg');
    img.minFilter = THREE.LinearFilter;
    this.material = new THREE.MeshBasicMaterial({
      opacity: 1,
      alphaMap: img,
      depthTest: true,
      transparent: true,
      color: new THREE.Color(color),
      blending: THREE.AdditiveBlending
    });
  }
  createBodyMaterial(color) {
    this.bodyMaterial = new THREE.MeshBasicMaterial({ color });
  }
}
